package com.sbr.seb.wicket.page;

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;

import com.sbr.seb.entity.Server;
import com.sbr.seb.entity.checklist.Question;
import com.sbr.seb.entity.composants.Category;
import com.sbr.seb.entity.server.Mantis;
import com.sbr.seb.entity.server.Tomcat;

/**
 * Homepage
 */
public class ServerManagerPage extends BasePage {

    public ServerManagerPage() {
    	super();
    	List<Server> serverList = new ArrayList<Server>();
    	serverList.add(new Tomcat());
    	serverList.add(new Mantis());
    	
    	add( new ListView<Server>("serverList", serverList) {

			@Override
			protected void populateItem(ListItem<Server> item) {
				Server server = item.getModelObject();
				item.add(new Label("name", server.getName()));
				item.add(new Label("type", server.getType().name()));
				item.add(new Label("host", server.getHost()));
				item.add(new Label("port", server.getPort()));
				item.add(new Label("login", server.getLogin()));
				item.add(new Label("password", server.getPassword()));
				
				if (item.getIndex() %2 == 0) {
					item.add(new SimpleAttributeModifier("class", "even"));
				} else {
					item.add(new SimpleAttributeModifier("class", "odd"));
				}
				
			}
    		
    	});
    	
    	add(new BookmarkablePageLink("addServerLink", AddServerPage.class));
    	
    }
}
